package com.ezjie.ielts.module_main;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;

import com.ezjie.ielts.R;
import com.ezjie.ielts.core.base.BaseFragmentActivity;
import com.ezjie.ielts.util.DownloadUtil;
import com.ezjie.ielts.util.PreferencesUtil;
import com.ezjie.ielts.util.UmengPages;
import com.igexin.sdk.PushManager;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.umeng.analytics.MobclickAgent;

@ContentView(R.layout.activity_splash)
public class SplashActivity extends BaseFragmentActivity {

	private boolean copySuccess;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ViewUtils.inject(this);

		// 发送策略
		MobclickAgent.updateOnlineConfig(this);
		// 禁止默认的页面统计方式， 默认的只针对只是activity的应用
		MobclickAgent.openActivityDurationTrack(false);
		// 测试模式，正式发布时，要去掉
//		MobclickAgent.setDebugMode(true);
		// 个推初始化
		PushManager.getInstance().initialize(this);

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				goMainActivity();
				finish();
			}
		}, 1500);

//		boolean isFirst = PreferencesUtil.getBoolean(this, "isFirst", true);
//		if (isFirst) {
//			copySuccess = DownloadUtil.getInstance().copyDB2SD(this);
//		}
		// 复制单词数据库
		DownloadUtil.getInstance().copyWordDB2SD(this);
	}

	private void goMainActivity() {

//		if (copySuccess) {
//			PreferencesUtil.putBoolean(this, "isFirst", false);
//		}
		startActivity(new Intent(SplashActivity.this, NavigationActivity.class));
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		MobclickAgent.onPageStart(UmengPages.PAGE_SPLASH);
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		MobclickAgent.onPageEnd(UmengPages.PAGE_SPLASH);
	}

	@Override
	public void onClickEvent(View view) {

	}

}
